#include <iostream>
using namespace std;

struct ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

int main() {
    int N;
    cin>>N;
    ListNode *head = new ListNode(0);
    ListNode *cur = head;
    cin>>cur->val;
    for (int i = 1; i < N; i++) {
        int num;
        cin>>num;
        ListNode *newNode = new ListNode(num);
        cur->next = newNode;
        cur = newNode;
    }
    int maxVal = head->val;
    int minVal = head->val;
    int pos1 = 1;
    int pos2 = 1;
    cur = head;
    int count = 1;
    cur = head->next;
    count = 2;
    while (cur!= NULL) {
        if (cur->val > maxVal) {
            maxVal = cur->val;
            pos1 = count;
        }
        if (cur->val < minVal) {
            minVal = cur->val;
            pos2 = count;
        }
        cur = cur->next;
        count++;
    }
    cout<<"max="<<maxVal<<",pos1="<<pos1<<endl;
    cout<<"min="<<minVal<<",pos2="<<pos2<<endl;
    return 0;
}

